import be.kuleuven.cs.som.annotate.Basic;

/**
 * 
 * @author Dieter Castel, Jonas Devlieghere
 *
 */
public class Square {
	public static final double MAX_TEMPERATURE = 5000;
	public static final double MIN_TEMPERATURE = -200;
	
	public Square(double temperature){
		this.temperature = temperature;
	}
	
	
	/**
	 * Return the temperature of the square
	 * 	The temperature is the temperature of that square at the current moment.
	 */
	@Basic
	public double getTemperature(){
		return temperature;
	}
	
	/**
	 * 
	 * @param 	temperature
	 * 			The new temperature to be given to this square
	 * @post	The temperature of this square equals the given temperature if it doens't exceed it's range
	 * 			| if (isValidTemperature(temperature))
	 * 			| 	then new.temperature == temperature
	 * @throws 	IllegalArgumentException
	 * 			The square can not have this temperature
	 * 			| ! isValidTemperature(temperature)
	 */
	private void setTemperature(double temperature) throws IllegalArgumentException{
		if(isValidTemperature(temperature)){
			this.temperature = temperature;
		}else{
			throw new IllegalArgumentException();
		}
	}

	/**
	 * Helper-method to determine whether the temperature is betweet MIN_TEMPERATURE and MAX_TEMPERATURE
	 * @param 	temperature
	 * 			The temperature to be checked
	 * @return result == (temperature >= MIN_TEMPERATURE) && (temperature <= MAX_TEMPERATURE)
	 */
	private static boolean isValidTemperature(double temperature) {
		return (temperature >= MIN_TEMPERATURE) && (temperature <= MAX_TEMPERATURE);
	}
	
	private double temperature;
	
	/**
	 * Vragen aan assistent: getter en wat met andere temperatuurschaal? 1 punt vanaf -5
	 * @post	If the current temperature is above or minus 5 degrees the ColdDamage returns zero
	 * 			| if
	 * @return
	 */
	@Basic
	public int getColdDamage(){
		if(getTemperature() > -5){
			return 0;
		}else{
			double doubleColdDamage = (getTemperature()+4)/10;
			return (int) Math.abs(Math.floor(doubleColdDamage));
		}
	}
	
	
	
}
